from datetime import datetime
from typing import Optional
from pydantic import BaseModel, validator, Field


class TechnologyBase(BaseModel):
    level: str = Field(..., description="技术层面")
    tool_name: str = Field(..., description="工具名称")
    name: str = Field(..., description="技术/功能名称")


class TechnologyCreate(TechnologyBase):
    pass


class TechnologyUpdate(BaseModel):
    level: Optional[str] = Field(None, description="技术层面")
    tool_name: Optional[str] = Field(None, description="工具名称")
    name: Optional[str] = Field(None, description="技术/功能名称")


class TechnologySchema(TechnologyCreate):
    id: int = Field(..., description="ID")
    create_time: datetime = Field(..., description="创建时间")
    update_time: datetime = Field(..., description="更新时间")
    is_delete: int = Field(0, description="逻辑删除:0=未删除,1=删除")

    class Config:
        from_attributes = True
